package january4;

import java.util.Scanner;

/**
 * ClassName: ArraysOddEvenNumberSum
 * Package: january4
 * Description:判断数组中奇数偶数的个数并求和
 *
 * @Author fjorid
 * @Create 2025/1/4 18:05
 * @Version 1.0
 */
public class ArraysOddEvenNumberSum {
    public static void main(String[] args) {
        int array[];
        int oddCount,evenCount,oddSum,evenSum;
        oddCount=evenCount=oddSum=evenSum=0;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数组长度");
        int arraylength = scanner.nextInt();
        array = new int[arraylength];
        System.out.println("请输入"+arraylength+"数");
        for (int i = 0; i < arraylength; i++) {
            array[i] = scanner.nextInt();
        }
            for (int i = 0; i < array.length; i++) {
            if(array[i]%2 == 0) {
                evenCount++;
                evenSum += array[i];
            }
            if(array[i]%2 != 0){
                oddCount++;
                oddSum += array[i];
            }

            }

        System.out.println("奇数个数为"+oddCount+"奇数的和为"+oddSum+"偶数个数为"+evenCount+"偶数的和为"+evenSum);
    }
}
